package project.service;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import project.mapper.DepartmentMapper;
import project.pojo.Department;
import project.util.SqlSessionFactoryUtils;

import java.util.List;

public class DepartmentService {
    SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();

    public List<Department> selectNames(){
        SqlSession sqlSession = sqlSessionFactory.openSession();
        DepartmentMapper departmentMapper = sqlSession.getMapper(DepartmentMapper.class);
        List<Department> departments = departmentMapper.selectNames();
        sqlSession.close();
        return departments;
    }

}
